//创建切换图层函数
function showMap1() {
    map.removeLayer(map.getLayers().item(0));
    map.addLayer(openStreetMapLayer);
}
function showMap2() {
    map.removeLayer(map.getLayers().item(0));
    map.addLayer(stamenLayer)
}
function showMap3() {
    map.removeLayer(map.getLayers().item(0));
    map.addLayer(gaoDeMapLayer)
}
function showMap4() {
    map.removeLayer(map.getLayers().item(0));
    map.addLayer(chinaMap)
}
//显示隐藏图层功能
function DisplayMap() {
    //显示图层
    map.getLayers().item(0).setVisible(true);
}
function HideMap() {
    //隐藏地图
    map.getLayers().item(0).setVisible(false);

}
//放大缩小图层功能
function zoomIn() {
    map.getView().setZoom(map.getView().getZoom() + 1);
}
function zoomOut() {
    map.getView().setZoom(map.getView().getZoom() - 1);
}
//绘制功能（画点，画线，画面）
function DrawPoint(a) {
    let drawDiv = document.getElementById('draw');
    drawDiv.style.display = 'none';
    //将绘制控件添加到地图容器中
    map.addInteraction(point);
}
function DrawLine() {
    let drawDiv = document.getElementById('draw');
    drawDiv.style.display = 'none';
    //将绘制控件添加到地图容器中
    map.addInteraction(line);
}
function DrawPolygon() {
    let drawDiv = document.getElementById('draw');
    drawDiv.style.display = 'none';
    //将绘制控件添加到地图容器中
    map.addInteraction(polygon);
}
function ClearAll() {
    let drawDiv = document.getElementById('draw');
    drawDiv.style.display = 'none';
    //点击按钮清除绘制的要素
    source.clear();
    //移除绘制功能
    map.removeInteraction(point);
    map.removeInteraction(line);
    map.removeInteraction(polygon);
}
//全屏功能
function FullScreen() {
    if(document.fullscreenElement){
        // 如果是全屏状态，则退出全屏
        document.exitFullscreen();
        document.getElementById('fullMap').innerHTML = '全屏';
    }else{
        document.documentElement.requestFullscreen();
        document.getElementById('fullMap').innerHTML = '退出';
    }
}